package com.example.base.net

import com.example.base.entity.DictEntity
import com.example.base.entity.LoginEntity
import com.example.base.entity.NewsEntity
import com.example.base.entity.OrderCreateEntity
import com.example.base.entity.ParkEntity
import com.example.base.entity.ParkEntityItem
import com.example.base.entity.RepairEntity
import com.example.base.entity.RepairEntityItem
import com.example.base.entity.Res
import com.example.base.entity.SignEntity
import com.example.base.entity.SignEntityItem
import com.example.base.entity.VisitEntity
import com.example.base.entity.VisitEntityItem
import kotlinx.coroutines.flow.Flow
import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.Multipart
import retrofit2.http.PATCH
import retrofit2.http.POST
import retrofit2.http.PUT
import retrofit2.http.Part
import retrofit2.http.Path
import retrofit2.http.Query

interface ApiService {
    @POST(Cons.LOGIN_URL)
    fun login(
        @Query("password") password: String,
        @Query("username") username: String
    ): Flow<Res<LoginEntity>>

    @PUT(Cons.UPDATE_PWD_URL)
    fun updatePwd(@Query("newPwd") newPwd: String, @Query("userid") userid: Int): Flow<Res<Boolean>>

    @GET(Cons.PARK_TYPE_URL)
    fun parkType(@Path("spaceType") spaceType: String): Flow<Res<ParkEntity>>

    @POST(Cons.PARK_ADD_URL)
    fun parkAdd(@Body body: RequestBody): Flow<Res<ParkEntityItem>>

    @GET(Cons.DICT_URL)
    fun dict(): Flow<Res<DictEntity>>

    @GET(Cons.PARK_DETAIL_URL)
    fun parkDetail(@Path("id") id: Int): Flow<Res<ParkEntityItem>>

    @PUT(Cons.PARK_UPDATE_URL)
    fun parkUpdate(@Path("id") id: Int, @Body body: RequestBody): Flow<Res<ParkEntityItem>>

    @DELETE(Cons.PARK_DELETE_URL)
    fun parkDelete(@Path("id") id: Int): Flow<Res<Boolean>>

    @GET(Cons.PARK_AREA_URL)
    fun parkArea(@Path("areaId") areaId: Int): Flow<Res<ParkEntity>>

    @GET(Cons.PARK_CARNO_URL)
    fun parkCarNo(@Path("licensePlate") licensePlate: String): Flow<Res<ParkEntity>>

    @GET(Cons.PARK_STATUS_URL)
    fun parkStatus(@Path("spaceStatus") spaceStatus: String): Flow<Res<ParkEntity>>

    //报修
    @GET(Cons.REPAIR_URL)
    fun repair(): Flow<Res<RepairEntity>>

    @Multipart
    @POST(Cons.UPLOAD_URL)
    fun upload(
        @Part part: MultipartBody.Part,
        @Query("modulename") modulename: String,
        @Query("userid") userid: String
    ): Flow<Res<String>>

    @POST(Cons.REPAIR_ADD_URL)
    fun repairAdd(@Body body: RequestBody):Flow<Res<RepairEntityItem>>
    @PUT(Cons.REPAIR_UPDATE_URL)
    fun repairUpdate(@Path("id")id:Int,@Body body: RequestBody):Flow<Res<RepairEntityItem>>


    @GET(Cons.VISIT_URL)
    fun visit():Flow<Res<VisitEntity>>
    @POST(Cons.VISIT_ADD_URL)
    fun visitAdd(@Body body: RequestBody):Flow<Res<VisitEntityItem>>
    @GET(Cons.VISIT_STATUS_URL)
    fun visitStatus(@Path("status")status:String):Flow<Res<VisitEntity>>
    @GET(Cons.VISIT_NAME_URL)
    fun visitName(@Query("name")name:String):Flow<Res<VisitEntity>>
    @GET(Cons.VISIT_PURPOSE_URL)
    fun visitPurpose(@Query("purpose")purpose:String):Flow<Res<VisitEntity>>
    @Multipart
    @POST(Cons.UPLOAD_HEAD_URL)
    fun uploadHead(@Part part: MultipartBody.Part,@Query("userid")userid:String):Flow<Res<String>>

    @GET(Cons.NEWS_URL)
    fun news():Flow<Res<NewsEntity>>
    @PATCH(Cons.NEWS_CANCEL)
    fun newsCancel(@Path("id")id:Int):Flow<Res<Boolean>>

    @POST(Cons.SIGN_URL)
    fun sign(@Body body: RequestBody):Flow<Res<SignEntityItem>>
    @GET(Cons.SING_RECORD_URL)
    fun signRecord(@Path("userId")userid:String):Flow<Res<SignEntity>>




}